<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../../js/vue.min.js"></script>
    <script src="../../js/iview.min.js"></script>
    <link rel="stylesheet" href="../../css/iview.css">
</head>
<body>
<div id="app">
    <button @click="handleRef">通过Ref获取子组件实例</button>
    <component-a ref="comA"></component-a>

</div>
<script>
    Vue.component('component-a', {
        template: "<div>子组件</div>",
        data: function () {
            return {
                message: "子组件内容"
            }
        }
    })
    var app = new Vue({
        el: "#app",
        data: {},
        methods: {
            handleRef: function () {
                //通过$ref获取子组件实例
                var msg = this.$refs.comA.message;
                console.log(msg);
            }
        }
    })
</script>
</body>
</html>